<template>
  <div ref="modal">
    <div class="delete-modal-box">
      <div class="box-title">
        <h4>{{ title }}</h4>
        <span>X</span>
      </div>
      <div class="box-tip">
        <p>{{ content }}</p>
      </div>
      <div class="box-btn">
        <span>取消</span>
        <span>确定</span>
      </div>
    </div>
    <div class="cover" @click="coverClick"></div>
  </div>
</template>

<script>
export default {
  name: 'DeleteModalBox',
  props: {
    title: {
      type: String,
      default: '模态框标题'
    },
    content: {
      type: String,
      default: '模态框提示内容'
    }
  },
  components: {},
  data () {
    return {}
  },
  created () {},
  mounted () {},
  computed: {},
  methods: {
    coverClick () {
      this.$refs.modal.style.display = 'none'
    }
  },
  watch: {}
}
</script>

<style lang="less" scoped>
// 遮罩层样式
.cover {
  position: absolute;
  left: 0px;
  top: 0px;
  display: block;
  background: rgba(0, 0, 0, 0.9);
  width: 100%; /*宽度设置为100%，这样才能使隐藏背景层覆盖原页面*/
  height: 100%;
  filter: alpha(opacity=60); /*设置透明度为60%*/
  opacity: 0.6; /*非IE浏览器下设置透明度为60%*/
  z-index: 999;
}

.delete-modal-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  border-radius: 10px;
  background-color: #fff;
  z-index: 9999;

  .box-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 40px;
    font-size: 14px;
    border-bottom: 1px solid #d4d4d4;

    > h4 {
      padding-left: 10px;
    }

    > span {
      padding-right: 10px;
    }
  }

  .box-tip {
    padding: 30px 0;
    text-align: center;
    border-bottom: 1px solid #d4d4d4;
    font-size: 14px;
  }

  .box-btn {
    display: flex;
    justify-content: flex-end;
    padding: 10px 15px 10px 0;
    font-size: 14px;

    span:first-child {
      margin-right: 5px;
    }

    span {
      display: block;
      padding: 7px 10px;
      color: #fff;
      background-color: #6394e5;
      border-radius: 5px;
    }
  }
}
</style>
